package com.jdjw.modules.migrantworkssign.service.impl;

import com.jdjw.common.ResponseResult;
import com.jdjw.modules.migrantworkssign.entity.MigrantWorksSign;
import com.jdjw.modules.migrantworkssign.entity.MigrantWorksSignVo;
import com.jdjw.modules.migrantworkssign.mapper.MigrantWorksSignMapper;
import com.jdjw.modules.migrantworkssign.service.MigrantWorksSignService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 务工人员库 服务实现类
 * </p>
 *
 * @author fq
 * @since 2021-07-27
 */
@Service
public class MigrantWorksSignServiceImpl extends ServiceImpl<MigrantWorksSignMapper, MigrantWorksSign> implements MigrantWorksSignService {

    @Autowired
    private MigrantWorksSignMapper migrantWorksSignMapper;

    @Override
    public ResponseResult queryAll(MigrantWorksSignVo migrantWorksSignVo) {
        ResponseResult rrt=new ResponseResult();
        //记录数的起始位置
        int start=migrantWorksSignVo.getPage()*migrantWorksSignVo.getRow()-migrantWorksSignVo.getRow();
        migrantWorksSignVo.setPage(start);
        List<MigrantWorksSign> migrantWorksSigns = migrantWorksSignMapper.queryAll(migrantWorksSignVo);
        if(migrantWorksSigns!=null){
             rrt.setCode(200);
             rrt.setMsg("查询成功");
             rrt.setData(migrantWorksSigns);
        }else{
            rrt.setCode(500);
            rrt.setMsg("查询失败");
            rrt.setData(null);
        }
        return rrt;
    }

    @Override
    public ResponseResult edit(String sqlEdit) {
        ResponseResult rrt=new ResponseResult();
        Boolean edit = migrantWorksSignMapper.edit(sqlEdit);
        if(edit){
            rrt.setCode(200);
            rrt.setMsg("编辑成功");
        }else{
            rrt.setCode(500);
            rrt.setMsg("编辑失败");
        }
        return rrt;
    }

    @Override
    public Integer queryPersonCount(Map<String, Object> param) {
        return migrantWorksSignMapper.queryPersonCount(param);
    }

    @Override
    public List<Map<String, Object>> queryPersonInfo(Map<String, Object> param) {
        return migrantWorksSignMapper.queryPerson(param);
    }

    @Override
    public void updateWorkerInfoById(String[] param) {
        migrantWorksSignMapper.updateWorkerStatus(param);
    }
    @Override
    public void updateWorksIsCompleteInfo(Map<String, Object> param) {
        this.migrantWorksSignMapper.updateWorksIsComplete(param);
    }
}
